<template>
	<view class="login-page">
		<view class="detail-item">
			<view class="item-title">
				昵称
			</view>
			<view>
				<u--input inputAlign="right" placeholderStyle="textAlign:'right'" placeholder="请输入新昵称" border="none"
					v-model="info.nickname"></u--input>
			</view>
		</view>
		<view class="btn">
			<u-button @click="goname" shape="circle" size="large" color="#333333" type="primary" text="确认修改"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {}
			}
		},
		onLoad() {
			this.userinfo()
		},
		methods: {
			goname() {
				uni.showLoading({
					mask: true
				})
				let params = {
					nickname: this.info.nickname
				}
				this.$Request({
					method: 'POST',
					data: params,
					url: '/user/editInfo'
				}).then(res => {
					if (res.data.code == 1) {
						uni.hideLoading()
						uni.showToast({
							title: '修改成功！',
							icon: 'none'
						})
						this.userinfo()
					} else {
						uni.hideLoading()
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},
			userinfo() {
				this.$Request({
					method: 'POST',
					url: '/user/getUserInfo'
				}).then(res => {
					if (res.data.code == 1) {
						this.info = res.data.data
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.login-page {
		padding: 30rpx;

		.detail-item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #f5f6fa;
			padding: 30rpx;
			border-radius: 40rpx;
			font-size: 28rpx;
			margin-top: 30rpx;

			.item-title {
				font-weight: 700;
			}

			.special {
				display: flex;
				align-items: center;

				.code-btn {
					margin-left: 20rpx;
					font-size: 24rpx;
					color: #fff;
					background-color: #00bfff;
					padding: 15rpx 20rpx;
					border-radius: 20rpx;
				}
			}

			.type {
				display: flex;
				align-items: center;

				text {
					margin-right: 10rpx;
				}
			}
		}

		.btn {
			margin-top: 30rpx;
		}

		.test {
			font-size: 30rpx;
			color: #5c616f;
			margin-top: 20rpx;

			.test-item {
				display: flex;
				align-items: center;
				padding: 10rpx 0;

				.item-text {
					margin-left: 20rpx;
				}
			}
		}
	}
</style>